package top.jiug.k_scheduled.service;

import org.springframework.stereotype.Service;
import top.jiug.k_scheduled.entity.User;
import top.jiug.k_scheduled.mapper.UserMapper;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {

    @Resource
    private UserMapper userMapper;


    public void addUser(User user) {
        userMapper.insert(user);
    }

    public void deleteUser(int id) {
        userMapper.delete(id);
    }

    public void editUser(User user)  {
        userMapper.update(user);
    }

    public List<User> queryUserList(){
        return userMapper.select();
    }

    public User getUserById(int id){
        List<User> userById = userMapper.getById(id);
        if (userById.size()==0){
            return null;
        }else{
            return userById.get(0);
        }
    }
}
